<?php
// +----------------------------------------------------------------------
// | xiongrui [ WE CAN DO IT JUST THINK IT ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013 http://www.xiongrui.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: molong <molong@tensent.cn> <http://www.xiongrui.cn>
// +----------------------------------------------------------------------

namespace app\admin\controller;
use app\common\controller\Admin;

class Game extends Admin {
  protected $Coupon;
  protected $CouponList;
  public function _initialize() {
		parent::_initialize();
    $this->GD = model('game_dzphistory');
    $this->WxUser = db('WxUser');
	}
  public function dzphistory($keyword=null) {
    if($keyword){
      $idarr = $this->WxUser->where('nickname','like','%'.$keyword.'%')->column('id');
    }

    if($idarr){
      $list = $this->GD->where('user_id','in',$idarr)->order('id desc')->paginate(20,false,array('query' => $this->request->param()));
    }else{
      $list = $this->GD->order('id desc')->paginate(20,false,array('query' => $this->request->param()));
    }





    $this->assign('list', $list);
		$this->setMeta('抽奖记录');
		return $this->fetch();
	}


  public function toogleexchange($id, $value = 1) {
		$result = db('game_dzphistory')->where(array('id' => $id))->setField(array('status' => $value));
		if ($result !== false) {
			return $this->success('操作成功！');
		} else {
			return $this->error('操作失败！');
		}
	}

  public function offlinepay(){
    vendor("phpqrcode.phpqrcode");
    //$QRcode = new \QRcode();
    $data = "http://www.xgw0851.com/index/cart/pay/xstatus/1";
    //echo $data;exit();
    // 纠错级别：L、M、Q、H
    $level = 'L';
    // 点的大小：1到10,用于手机端4就可以了
    $size = 10;
    // 下面注释了把二维码图片保存到本地的代码,如果要保存图片,用$fileName替换第二个参数false
    $path = "uploads/";
    // 生成的文件名
    $fileName = $path.'xxfk.png';

    if(!file_exists($fileName )){
      \QRcode::png($data, $fileName, $level, $size);
    }
    $this->assign('filename', '/'.$fileName);
    $this->assign('url', $data);
		$this->setMeta('线下付款说明');
		return $this->fetch();
  }

}

 ?>
